package com.ohuang.test_compose

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import com.ohuang.test_compose.ui.theme.Test_composeTheme

class MainActivity2 : AppCompatActivity() {
    private var isChange = false
    private var compose:ComposeView?=null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.layout_main2)
        compose=findViewById(R.id.Cv_main2)//1.3以后才可以 implementation 'androidx.appcompat:appcompat:1.3.0'
        compose?.setContent {
            Test_composeTheme {
                // A surface container using the 'background' color from the theme
                Surface(color = MaterialTheme.colors.background) {
                    var s = intent.getStringExtra("1")
                    Greeting2(s + "")
                }
            }
        }

    }

    @Composable
    fun Greeting2(name: String) {
        Column() {
            Text(text = "Hello ${name}!", modifier = Modifier.clickable {

            })
        }
    }
}


@Composable
fun test(i: Boolean) {
    if (i) {
        var a = remember {
            mutableStateOf("a")
        }
    }
    var b = remember {
        mutableStateOf(0)
    }

}


